/* $Id: log.c 13 2006-12-14 21:07:45Z judas $ */

#include <nih/cdefs.h>

#include <nih/log.h>

#include <string.h>

FILE *nih_log_file = NULL;

int nih_log_sysprio = LOG_ERR;
int nih_log_errprio = LOG_INFO;
int nih_log_logprio = LOG_INFO;

int nih_log_errtype = NIH_LOG_ON;
bool nih_log_ext = true;

#define DT_PH "yyyy-mm-dd hh:mm:ss.uuuuuu "
#define DT_FMT "%Y-%m-%d %H:%M:%S.%06i "

/*
 * prefix: D, I, N, W, E, C, A, M
 */
int nih_log_full(const char *file, const char *fnc, int line, int sysprio,
                 int errprio, int logprio, FILE *logfile, int errtype,
                 bool ext, int errn, int prio, const char *format,
                 va_list ap)
{
#if 0
        char dt[sizeof(DT_PH) + 1];
        char *ffl;
        char *estr;

        if (prio > syslog_prio && prio > stderr_prio
            && (!nih_logfile || prio > logfile_prio))
                return 0;

        if (ext) {
                struct timeval_t;

                strftime(dt, sizeof(dt), DT_FMT, &tm);
                asprintf(&ffl, " in %s (%s:%i)", fnc, file, line);
        }

        if (errn)
                asprintf(&estr, ": %s ", strerror(errn));

        // stderr, logfile: ("%s%s%s%s", dt, msg, estr, ffl);

        syslog(prio, "%s%s%s", msg, estr, ffl);
#endif
        return 0;
}

